package com.fayou.oder.controller;


import com.fayou.cloud.entites.CommonResult;
import com.fayou.cloud.entites.Payment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
@RequestMapping("/consumer/payment")
public class OrderController {
    private static final String PAYMENT_URL="http://CLOUD-PAYMENT-SERVICE";
    @Resource
    RestTemplate restTemplate;
    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("/selectOne")
    public CommonResult selectOne(@RequestParam Integer id) {
        CommonResult payment = restTemplate.getForObject(PAYMENT_URL + "/payment/selectOne?id=" + id, CommonResult.class);
        return payment;
    }

}
